<template>
  <view v-if="show" class="gift-modal-container" 
    
  >
   <view class="main-container">
      <view class="main-wrapper">
        <!-- 默认定位，当背景 -->
        <cover-image style="position: fixed;left: 0;right: 0;top: 0;bottom: 0;z-index: 999;" mode="widthFix" :src="staticImgs.bg"></cover-image>
        <!-- 默认定位，当背景 -->
        <cover-image class="flash-img rotating" mode="widthFix" :src="staticImgs.flash"></cover-image>
        <!-- 绝对定位，层级前置 -->
        <cover-image class="main-img" mode="widthFix" :src="staticImgs.main"></cover-image>
      </view>
      <view class="btns-wrapper">
        <cover-image @click="confirmHandle" mode="widthFix" class="btn-img" :src="staticImgs.btn"></cover-image>
        <cover-image class="hand-img-abs pointing" mode="widthFix" :src="staticImgs.hand"></cover-image>
      </view>
   </view> 
  </view>
  
<!--  <view v-if="show" class="gift-modal-container"
    :style="{'background-image':`url(${staticImgs.bg})`}"
  >
   <view class="main-container">
      <view class="main-wrapper">
        
        <image class="flash-img rotating" mode="widthFix" :src="staticImgs.flash"></image>
        
        <image class="main-img" mode="widthFix" :src="staticImgs.main"></image>
      </view>
      <view class="btns-wrapper">
        <image @click="confirmHandle" mode="widthFix" class="btn-img" :src="staticImgs.btn"></image>
        <image class="hand-img-abs pointing" mode="widthFix" :src="staticImgs.hand"></image>
      </view>
   </view> 
  </view> -->
</template>

<script>
  export default {
    name: "GiftModal",
    props: {
      visible: {
        type: Boolean,
        default: false
      }
    },
    watch: {
      visible(val) {
        console.log('-----visible-----',val)
        this.show = val
      }
    },
    data() {
      return {
        staticImgs:{
          bg: this.imgBaseURL + '/scl/gift-modal/gift-modal-bg.png',
          btn: this.imgBaseURL + '/scl/gift-modal/gift-btn-v2.png',
          flash: this.imgBaseURL + '/scl/gift-modal/gift-flash.png',
          main: this.imgBaseURL + '/scl/gift-modal/gift-main-v2.png',
          hand: this.imgBaseURL + '/scl/gift-modal/gift-hand.png',
        },
        show: false,
      }
    },
    methods: {
      confirmHandle(){
        this.$emit('confirm')
      }
    }
  }
</script>

<style lang="scss" scoped>
  
  /* 定义旋转动画效果 */
  @keyframes rotate {
   0% {
              transform: rotate(0);
          }
  
          25% {
              transform: rotate(90deg);
          }
  
          50% {
              transform: rotate(180deg);
          }
  
          75% {
              transform: rotate(270deg);
          }
  
          100% {
              transform: rotate(360deg);
          }

  }
  
  .rotating{
    animation: rotate 5s linear infinite;
    -webkit-animation: rotate 5s linear infinite;
  }
  
  
  /* 定义旋转动画效果 */
  @keyframes point {
  	0% {
  	    transform: translateZ(0);
  	}
  	// 5% {
  	//     transform: translate3d(5px,5px,0);
  	// }
  	15% {
  	    transform: translate3d(-5px,-5px,0);
  	}
  	25% {
  	    // transform: translate3d(5px,5px,0);
        transform: translate3d(0,0,0);
  	}
  	45% {
  	    transform: translate3d(-5px,-5px,0);
  	}
  	55% {
  	    // transform: translate3d(5px,-5px,0);
        transform: translate3d(0,0,0);
  	}
  	65% {
  	    transform: translate3d(-5px,-5px,0);
  	}
  	80% {
  	    // transform: translate3d(5px,5px,0);
        
  	}
  	100% {
  	    transform: translate3d(0,0,0);
  	}
  
}
  
  .pointing{
    animation: point 3s linear infinite;
    -webkit-animation: point 3s linear infinite;
  }
  
  
  
  .gift-modal-container{
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999;
    box-sizing: border-box;
    background-size: 100% 100%; 
    padding-top: 18vh;
    // background-color: red;
    
    .main-wrapper{
      height: 784rpx;
      width: 624rpx;
      margin: auto;
      position: relative;
      
      // .flash-img{
      //   width: 624rpx;
      //   height: 624rpx;
      //   margin-top: 82rpx;
      // }
      .flash-img{
        width: 624rpx;
        height: 624rpx;
        margin-top: 82rpx;
        position: absolute;
        z-index: 999;
        left: 0;
        right: 0;
      }
      .main-img{
        position: absolute;
        z-index: 999;
        width: 552rpx;
        top: 0;
        left: 36rpx;
        // right: 0;
        bottom:  0;
      }
    }
    .btns-wrapper{
      position: relative;
      margin:  auto;
      margin-top: 42rpx;
      display: flex;
      justify-content: center;
      width: 290rpx;
      // width: 100%;
      height: 150rpx;
      overflow: initial;

      

      
      .btn-img{
        width: 290rpx;
        height: 100rpx;
        position: absolute;
        z-index: 999;
        left: 0;
        top: 0;
      }
      .hand-img-abs{
        width: 130rpx;
        height: 114rpx;
        position: absolute;
        z-index: 999;
        right: -84rpx;
        top: 38rpx;
      }
    }
  }
</style>